<?php include('app/admin/welcome/html/meta.html');?>
<?php include('app/admin/welcome/html/header.html');?>
<?php include('app/admin/welcome/html/menu.html');?>

<section class="Hui-article-box">
	<nav class="breadcrumb"><i class="Hui-iconfont"></i>
		<a href="index.php?a=admin&b=welcome&c=index" class="maincolor">首页</a>
		<span class="c-999 en">&gt;</span>
		<span class="c-666">权限修改</span>
		<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
	</nav>
	<div class="Hui-article">

		<article class="page-container">
			<form class="form form-horizontal" id="form-article-add" action="index.php?a=admin&b=permission&c=update" method="post" enctype="multipart/form-data">
				<input style="display: none;" type="text" name="Id" id="Id" value="<?php echo $re['Id']?>" />
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>角色名称：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" value="<?php echo $re['name']?>" placeholder="" id="roleName" name="name">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">备注：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" value="<?php echo $re['notes']?>" placeholder="" id="" name="notes">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-2">拥有权限：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<dl class="permission-list">

							<dd>
								<?php foreach($permission as $k=>$v){?>
								<?php if($v['pid']==0){?>
								<dl class="cl permission-list2">
									<dt>
								<label class="">
									<input type="checkbox" value="<?php echo $v['Id']?>" <?php if(in_array($v['Id'], $re['permission_id'])){echo "checked='checked'";}?> name="permission_id[]" id="user-Character-0-0">
									<?php echo $v['name']?></label>
							</dt>
									<dd>
										<?php foreach($permission as $key=>$val){?>
										<?php if($v['Id']==$val['pid']){?>
										<label class="">
									<input type="checkbox" value="<?php echo $val['Id']?>" <?php if(in_array($val['Id'], $re['permission_id'])){echo "checked='checked'";}?> name="permission_id[]" id="user-Character-0-0-0"/>
									<?php echo $val['name']?></label>
										<?php }?>
										<?php }?>
									</dd>
								</dl>
								<?php }?>
								<?php }?>

							</dd>
						</dl>

					</div>
				</div>
				<div class="row cl">
					<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
						<button type="submit" class="btn btn-success radius" id="admin-role-save" name=""><i class="icon-ok"></i> 确定</button>
					</div>
				</div>
			</form>
		</article>
	</div>
</section>

<?php include('app/admin/welcome/html/footer.html');?>

<!--请在下方写此页面业务相关的脚本-->

<!-- 配置文件 -->
<script type="text/javascript" src="static/lib/ueditor/1.4.3/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="static/lib/ueditor/1.4.3/ueditor.all.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
	$(function() {
		$(".permission-list dt input:checkbox").click(function() {
			$(this).closest("dl").find("dd input:checkbox").prop("checked", $(this).prop("checked"));
		});
		$(".permission-list2 dd input:checkbox").click(function() {
			var l = $(this).parent().parent().find("input:checked").length;
			var l2 = $(this).parents(".permission-list").find(".permission-list2 dd").find("input:checked").length;
			if($(this).prop("checked")) {
				$(this).closest("dl").find("dt input:checkbox").prop("checked", true);
				$(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked", true);
			} else {
				if(l == 0) {
					$(this).closest("dl").find("dt input:checkbox").prop("checked", false);
				}
				if(l2 == 0) {
					$(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked", false);
				}
			}
		});

		$("#form-admin-role-add").validate({
			rules: {
				roleName: {
					required: true,
				},
			},
			onkeyup: false,
			focusCleanup: true,
			success: "valid",
			submitHandler: function(form) {
				$(form).ajaxSubmit();
				var index = parent.layer.getFrameIndex(window.name);
				parent.layer.close(index);
			}
		});
	});
</script>
<!--/请在上方写此页面业务相关的脚本-->

</body>

</html>